import java.util.*;

public class Main {

    public static int n;
    public static int m;
    public static int[] arr;
    public static List<Long> list = new ArrayList<>();

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        n = sc.nextInt();
        m = sc.nextInt();
        arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }

        dfs(0);

        long ret = 0;
        for (long num : list) {
            ret = Math.max(ret, num);
        }

        System.out.println(ret);

        sc.close();
    }

    public static void dfs(int index) {
        if (index == n) {
            long sum = 0;
            for (int i = 0; i < n; i++) {
                sum += arr[i];
            }
            list.add(sum);
            return;
        }

        for (int i = index; i < n; i++) {
            //翻转
            int num1 = arr[i]; //保存翻转之前的数字
            int num2 = overturn(num1); //翻转之后的数字
            arr[i] = num2;
            dfs(i + 1);
            //回溯
            arr[i] = num1;

            //不翻转
            dfs(i + 1);
        }


    }

    /**
     * 翻转
     * @param num
     * @return
     */
    public static int overturn(int num) {
        Stack<Integer> stack = new Stack<>();

        while (num != 0) {
            stack.push(num % 2);
            num /= 2;
        }

        //去除前导零
        while (!stack.isEmpty() && stack.peek() == 0) {
            stack.pop();
        }

        int ret = 0;
        int size = stack.size();
        int count = 0;
        while (size > 0) {
            ret += Math.pow(2, count++) * stack.pop();
//            count++;
            size--;
        }
        return ret;
    }

    public static void main1(String[] args) {
        System.out.println(overturn(11));
    }
}
